import 'package:flutter/widgets.dart';
import 'package:flutter_app/base/base_presenter.dart';

abstract class BaseFulWidget extends StatefulWidget {}

abstract class BaseState<P extends BasePresenter, W extends BaseFulWidget>
    extends State<W>{
  P _presenter;

  P createPresenter();

  P get presenter => _presenter;

  @override
  void initState() {
    super.initState();
    if (_presenter == null) {
      _presenter = createPresenter();
    }
  }

  @override
  void dispose() {
    super.dispose();
    if (_presenter != null) {
      _presenter.detachView();
      _presenter = null;
    }
  }
}
